package L01;
//join并不是只让主线程等待其他的线程

public class T18 {
    public static void main (String[] args) {
        Thread t1=new Thread (()->{
            try {
                Thread.sleep (1000);
            } catch (InterruptedException e) {
                throw new RuntimeException (e);
            }
            System.out.println ("t1线程结束");
        });
        Thread t2=new Thread (()->{
            try {
                t1.join ();
                //哪个线程调用join()，哪个线程就阻塞
            } catch (InterruptedException e) {
                throw new RuntimeException (e);
            }
            try {
                Thread.sleep (1000);
            } catch (InterruptedException e) {
                throw new RuntimeException (e);
            }
            System.out.println ("t2线程结束");
        });

        t1.start ();
        t2.start ();
    }
}
